<template>
<div>
	<el-table
						:data="tableData"
						border
						:stripe="true"
						style="width: 100%"
				
					>
						<el-table-column type="selection" width="55"> </el-table-column>
						<el-table-column type="index" label="序号" width="60">
						</el-table-column>
						<el-table-column prop="name" label="主机名称"> </el-table-column>
						<el-table-column prop="hostGuid" label="GUID"> </el-table-column>
						<el-table-column prop="hostType" label="主机类型" width="120">
							<template slot-scope="scope">
								<span>{{ scope.row.hostGuid | hostTypeFilter }}</span>
								<el-button
								v-if="scope.row.hostGuid.slice(0, 2)=='3A'" 
								size="mini"
								@click="updata(scope.row.id)"
								type="primary"
								plain
								>升级</el-button>
							</template>
						</el-table-column>
						<el-table-column prop="status" label="状态" width="80">
							<template slot-scope="scope">
								<span>{{ scope.row.status === 'O' ? '在线' : '离线' }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="address" label="所属区域"> </el-table-column>
					
						<el-table-column prop="locationDesc" label="安装位置说明">
						</el-table-column>
					
						<el-table-column prop="creationTime" label="安装时间" width="200">
						</el-table-column>
					</el-table>
</div>
</template>

<script>
import ajax from "@/utils/ajax";
const hostType_F = [{ value: 58, name: '619A' }]
export default {
	data() {
		return {
			tableData:[]
		}
	},
	props: {
    hostid: {
      type: Number,
    },
		organId: {
      type: Number,
    },
   
  },
	created() {
		this.gethostData()
	},
	computed: {
		HostId(){
			return this.hostid
		},
		OrganId(){
			return this.organId
		}
	},
	methods:{
		gethostData(){
			let self =this
			ajax.post({
          url: this.$API.getHostList,
          data: { 	id: this.hostid,
					page:1,
					pageSize: 10,
					searchStr: '',},
          success: (response) => {
           self.tableData =response.data
          },
        });
		},
		updata(id){
				let self =this
			  window.open(this.$API.getUp619b +"?hostId=" + id +"&organId=" + self.organId);
		}
	},
	filters: {
		hostTypeFilter(value) {
			if(value.slice(0, 2) == '3A'){
				return '619A'
			}
			else
			{return '619B'}
		},
	},
	watch:{
		HostId(){
	
				this.gethostData()
		}
	}
}

</script>
<style scoped>

.updata-btn{
	display:flex;
	align-items: center;
	justify-content: space-between;
}
::v-deep.el-table--striped .el-table__body tr.el-table__row--striped td {
   background: inherit;
}
</style>